import { BasicLayout } from '../layouts'
import { RouterMap } from '../router/typings'
import RouteView from '@/layouts/RouteView.vue'

export const asyncRouterMap: RouterMap[] = [
  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: { title: '主页' },
    redirect: '/dashboard',
    children: [
      {
        path: '/dashboard',
        name: 'dashboard',
        component: () => import('@/views/dashboard/Workplace.vue'),
        meta: { title: 'dashboard' }
      },
      // forms
      {
        path: '/form',
        redirect: '/form/base-form',
        component: RouteView,
        name: 'Form',
        meta: { title: 'form', icon: 'form', permission: ['form'] },
        children: [
          {
            path: '/form/base-form',
            name: 'BaseForm',
            component: () => import('@/views/form/BasicForm.vue'),
            meta: { title: 'basic-form', keepAlive: true, permission: ['form'] }
          },
          {
            path: '/form/step-form',
            name: 'StepForm',
            component: () => import('@/views/form/StepForm.vue'),
            meta: { title: 'step-form', keepAlive: true, permission: ['form'] }
          },
          {
            path: '/form/advanced-form',
            name: 'AdvanceForm',
            component: () => import('@/views/form/AdvancedForm.vue'),
            meta: { title: 'advanced-form', keepAlive: true, permission: ['form'] }
          }
        ]
      }
    ]
  },
  {
    path: '/:pathMatch(.*)*',
    redirect: '/404',
    hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */

export const constantRouterMap: RouterMap[] = [
  {
    path: '/user/login',
    name: 'login',
    component: () => import('@/views/user/Login.vue')
  },
  {
    path: '/404',
    component: () => import('@/views/exception/404.vue')
  },
  ...asyncRouterMap
]
